/* SPDX-License-Identifier: GPL-2.0 */
/*
 * Author   : Ryan Shen
 * Contract : shentao@huawei.com
 * File     : hi_drv_wdt.h
 * Describe : hisilicon watchdog driver.
 * Platform : ARM Cortex-A9 & Linux 2.6.34.10
 * Log      : 2013-01-23 : init version completed.
 *
 * Copyright (c) 2010-2012 by Hisilicon. All rights reserved.
 */
#ifndef __HI_WDT_H__
#define __HI_WDT_H__
#include <linux/types.h>
/*
 * Struct definition
 */
/* wdt work mode enum */
enum HI_WDT_WORK_MODE_E {
	HI_WDT_USER_MODE_E = 0x0,	/* user mode, clear by user */
	HI_WDT_AUTO_MODE_E,		/* auto mode, period is 300s,
					 * and the watchdog is cleared
					 * every 270s
					 */
};

/* wdt attr */
struct hi_wdt_attr_s {
	enum HI_WDT_WORK_MODE_E em_mode;	/* work mode: default auto */
	unsigned long  ui_period;		/* period: 1 - 300 secs */
	// unsigned long  ui_warning_thr;	/* alarm threshold: 1 - 300 secs */
	/* when the user does not reset the watchdog at
	 * second (ui_period - 1), invoke the secondary function
	 * to record the information before the board reset.
	 */
	void (*wdt_proc)(void);
};

/*
 * Function declaration
 */
/* attr get/set funcions */
extern int hi_kernel_wdt_attr_set(struct hi_wdt_attr_s *pst_attr);
extern int hi_kernel_wdt_attr_get(struct hi_wdt_attr_s *pst_attr);
/* clear dog */
extern void hi_kernel_wdt_clear(void);

/* wdt handler called by system timer */
extern void hi_kernel_wdt_proc(void);

/* wdt cfg en */
void hi_kernel_wdt_en_set(uint32_t ui_flag);

#endif /*__HI_WDT_H__*/
